<template>
  <div>
    <ul class="mui-table-view">
      <li class="mui-table-view-cell mui-media" v-for="item1 in newsList" :key="item1.cai">
        <router-link to="/home/newsinfo">
          <img class="mui-media-object mui-pull-left" :src="item1.profile_image" />
          <div class="mui-media-body">
            <h1>{{item1.name}}</h1>
            <p class="mui-ellipsis">
              <span>发表时间:{{item1.passtime}}</span>
              <span>点击:{{item1.love}}次</span>
            </p>
          </div>
        </router-link>
      </li>
    </ul>
  </div>
</template>

<script>
import { Toast } from "mint-ui";

export default {
  data() {
    return {
      // 新闻列表
      newsList: []
    };
  },
  created() {
    this.getNewsList();
  },
  methods: {
    getNewsList() {
      this.$http
        .get("https://www.apiopen.top/satinApi?type=1&page=1")
        .then(result => {
          if (result.body.code == 200) {
            //    成功的时候需要把数据绑定到data上
            Toast("获取列表成功");
            console.log(result.body.data)
            this.newsList = result.body.data;
          } else {
            Toast("获取加载列表失败......");
          }
        });
    }
  }
};
</script>

<style scoped>
.mui-table-view li h1 {
  font-size: 14px;
}
.mui-table-view .mui-ellipsis {
  font-size: 12px;
  color: #226aff;
  display: flex;
  /* 相当于左右浮动，这里使用的是flex布局实现的 */
  justify-content: space-between;
}
</style>
